package itbour.onetouchshow.listener;

import android.view.View;

import com.lsjr.utils.NetUtils;

import itbour.onetouchshow.utils.T_;
import itbour.onetouchshow.utils.UIUtils;

public abstract class OnMultiClickListener implements View.OnClickListener {
    // 两次点击按钮之间的点击间隔不能少于1000毫秒
    public static int MIN_CLICK_DELAY_TIME = 2000;
    private static long lastClickTime;

    public abstract void onMultiClick(View v);

    @Override
    public void onClick(View v) {
        long curClickTime = System.currentTimeMillis();
        if ((curClickTime - lastClickTime) >= MIN_CLICK_DELAY_TIME) {
            // 超过点击间隔后再将lastClickTime重置为当前点击时间
            lastClickTime = curClickTime;
            if (NetUtils.isConnected(UIUtils.getContext())) {
                onMultiClick(v);
            } else {
                T_.showCustomToast("请检查网络");
            }

        }
    }
}